/*
 * @Author: c
 * @Date: 2024-01-08 07:20:59
 * @LastEditTime: 2024-03-21 18:50:30
 * @LastEditors: c
 * @Description: 创建歌手信息DTO
 * @FilePath: \music-web-backend\src\core\music\artist\dto\create-artist.dto.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */

import { Transform, Type } from "class-transformer";
import { IsArray, IsDate, IsEnum, IsNumber, IsOptional, IsString, Length, ValidateNested } from "class-validator";
import { BloodEnum } from "src/common/enums/blood.enum";
import { GenderEnum } from "src/common/enums/gender.enum";
import { UploadFile } from "src/common/type/file";

export class ArtistForm {

    @IsOptional()
    @IsNumber()
    id?: number;

    @Transform((value) => {

        return new Date(value)
    })
    @IsDate({
        message: "生日必须是日期"
    })
    birthday: Date;

    @IsOptional()
    @IsArray()
    @ValidateNested({ each: true })
    @Type(() => UploadFile)
    pictorialList: UploadFile[];


    @Transform((value) => +value)
    @IsEnum(GenderEnum, { message: "性别必须是男或者女" })
    gender: GenderEnum;

    @IsString({ message: "介绍文本格式不对" })
    introduce: string;

    @Transform(val => +val)
    @IsNumber({ allowNaN: false }, { message: "体重必须是数字类型", always: false })
    weight: number;

    @IsOptional()
    @IsArray()
    @ValidateNested({ each: true })
    @Type(() => UploadFile)
    pic: UploadFile[];

    // @Transform((value) => {
    //     debugger
    //     return BloodEnum[value] || value
    // })
    @IsEnum(BloodEnum, { message: "血型参数不正确" })
    blood: BloodEnum;

    @IsString({ message: "歌手的唯一Code文本格式不对" })
    artistCode: string;

    @IsString({ message: "出生地文本格式不对" })
    birthPlace: string;

    @IsOptional()
    @IsArray()
    @IsString({ message: "国家地区格式不对", each: true })
    nativeList: string[];

    @Length(2, 20, { message: "名字长度不超过20不低于2个字" })
    @IsString({ message: "名字文本格式不对" })
    name: string;
    @Length(2, 20, { message: "名字长度不超过20不低于2个字" })
    @IsString({ message: "名字文本格式不对" })
    pinyinName: string

    @IsString({ message: "地区标签文本格式不对" })
    region: string;

    @Transform(val => +val)
    @IsNumber({ allowNaN: false }, { message: "身高必须是数字类型", always: false })
    height: number;



}


export class FavoriteForm {
    @IsNumber()
    id: number;
  }